import { createRouter, createWebHistory } from "vue-router";
import home from "@/views/home/index.vue";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      // redirect: "video"
      meta: {
        title: "视频",
      },
      component: () => import("@/views/video/index.vue"),
    },
    {
      path: "/home",
      name: "home",
      component: home,
    },
    {
      path: "/video",
      name: "video",
      meta: {
        title: "视频",
      },
      component: () => import("@/views/video/index.vue"),
    },
    {
      path: "/applications",
      name: "applications",
      meta: {
        title: "地面作业指挥",
      },
      component: () => import("@/views/applications/index.vue"),
      children: [
        {
          path: "/groundLive",
          name: "groundLive",
          meta: {
            title: "地面作业指挥",
          },
          component: () => import("@/views/applications/groundLive/index.vue"),
        },
        // {
        //   path: "/aircraftLive",
        //   name: "aircraftLive",
        //   meta: {
        //     title: "飞机作业实况",
        //   },
        //   component: () =>
        //     import("@/views/applications/aircraftLive/index.vue"),
        // },
        {
          path: "/test",
          name: "test",
          meta: {
            title: "测试",
          },
          component: () => import("@/views/applications/test/index.vue"),
        },
      
        {
          path: "/satellite",
          name: "satellite",
          meta: {
            title: "卫星",
          },
          component: () => import("@/views/applications/satellite/index.vue"),
        },
        {
          path: "/commandPlan",
          name: "commandPlan",
          meta: {
            title: "指挥方案",
          },
          component: () => import("@/views/applications/commandPlan/index.vue"),
        },
      ],
    },
  ],
});

// 访问权限控制
router.beforeEach((to, from, next) => {
  window.test = (value) => {
    document.documentElement.style.setProperty(
      "--zoomin",
      value.fontSize + "px"
    );
  };
  

  next();
});

router.afterEach((to) => {
  // 修改标题
  document.title = `人影-${to.meta.title || ""}`;
});

export default router;
